package one.stand.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import one.stand.aop.ApiController;
import one.stand.model.ResultModel;
import one.stand.request.*;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("crmApi/dataCount")
@Api(description = "数据统计",tags="数据统计")
public class DataCountController extends BaseController {

    @PostMapping("personalData")
    @ApiOperation(value = "个人数据统计/企业数据统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "yearMonth", value = "查询日期(yyyy-mm)",  paramType = "String"),
            @ApiImplicitParam(name = "type", value = "1个人数据2企业数据", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "cardId", value = "员工名片ID（成员分析使用）", paramType = "Integer"),
    })
    @ApiController(isLogin = true, company = true,card = true,paramClass =FinanceRequest.class )
    public ResultModel personalData(@RequestAttribute FinanceRequest request) {
        
        return crmFegin.personalData(request);
    }

    @PostMapping("sevenData")
    @ApiOperation(value = "近7日成交额")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "yearMonth", value = "查询日期(yyyy-mm)",  paramType = "String"),
            @ApiImplicitParam(name = "type", value = "1个人数据2企业数据", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "cardId", value = "员工名片ID（成员分析使用）", paramType = "Integer"),
    })
    @ApiController(isLogin = true, company = true,card = true,paramClass =FinanceRequest.class)
    public ResultModel sevenData(@RequestAttribute FinanceRequest request) {
        
        return crmFegin.sevenData(request);
    }

    @PostMapping("dataSummary")
    @ApiOperation(value = "数据汇总")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "days", value = "时间（1,7,15,30），不传值时查总数据", paramType = "Integer"),
            @ApiImplicitParam(name = "type", value = "1个人数据2企业数据", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "cardId", value = "员工名片ID（成员分析使用）", paramType = "Integer"),
    })
    @ApiController(isLogin = true, company = true,card = true,paramClass =FinanceRequest.class)
    public ResultModel dataSummary(@RequestAttribute FinanceRequest request) {
        
        return crmFegin.dataSummary(request);
    }

    @PostMapping("turnoverRate")
    @ApiOperation(value = "成交率漏斗")
    @ApiController(isLogin = true, company = true,card = true,isParam = false)
    public ResultModel turnoverRate(@RequestAttribute TokenRequest tokenRequest) {
        FinanceRequest request=new FinanceRequest();
        BeanUtils.copyProperties(tokenRequest,request);
        return crmFegin.turnoverRate(request);
    }

    @PostMapping("newCustomerNum")
    @ApiOperation(value = "新增客户数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "days", value = "时间7,15,30天", paramType = "Integer"),
            @ApiImplicitParam(name = "type", value = "1个人数据2企业数据", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "cardId", value = "员工名片ID（成员分析使用）", paramType = "Integer"),
    })
    @ApiController(isLogin = true, company = true,card = true,paramClass =FinanceRequest.class)
    public ResultModel newCustomerNum(@RequestAttribute FinanceRequest request) {
        
        return crmFegin.newCustomerNum(request);
    }

    @PostMapping("followCustomerNum")
    @ApiOperation(value = "咨询客户数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "days", value = "时间7,15,30天", paramType = "Integer"),
            @ApiImplicitParam(name = "type", value = "1个人数据2企业数据", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "cardId", value = "员工名片ID（成员分析使用）", paramType = "Integer"),
    })
    @ApiController(isLogin = true, company = true,card = true,paramClass =FinanceRequest.class)
    public ResultModel followCustomerNum(@RequestAttribute FinanceRequest request) {
        
        return crmFegin.followCustomerNum(request);
    }

    @PostMapping("consultationNum")
    @ApiOperation(value = "跟进客户数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "days", value = "时间7,15,30天", paramType = "Integer"),
            @ApiImplicitParam(name = "type", value = "1个人数据2企业数据", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "cardId", value = "员工名片ID（成员分析使用）", paramType = "Integer"),
    })
    @ApiController(isLogin = true, company = true,card = true,paramClass =FinanceRequest.class)
    public ResultModel consultationNum(@RequestAttribute FinanceRequest request) {
        
        return crmFegin.consultationNum(request);
    }

    @PostMapping("activeCustomerNum")
    @ApiOperation(value = "近15日客户活跃数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "yearMonth", value = "查询日期(yyyy-mm)", paramType = "String"),
            @ApiImplicitParam(name = "type", value = "1个人数据2企业数据", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "cardId", value = "员工名片ID（成员分析使用）", paramType = "Integer"),
            @ApiImplicitParam(name = "seeUserId", value = "客户ID（客户分析使用）", paramType = "Integer"),
    })
    @ApiController(isLogin = true, company = true, card = true,paramClass =FinanceRequest.class)
    public ResultModel activeCustomerNum(@RequestAttribute FinanceRequest request) {
        
        return crmFegin.activeCustomerNum(request);
    }

    @PostMapping("addConsultRecord")
    @ApiOperation(value = "添加咨询记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "客户ID", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "cardId", value = "员工名片ID", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "companyId", value = "公司ID", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "sonsultType", value = "咨询类型1普通消息，2初始消息，3商品消息", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true, company = true,paramClass =ConsultRecordRequest.class)
    public ResultModel addConsultRecord(@RequestAttribute ConsultRecordRequest request) {
        
        return crmFegin.addConsultRecord(request);
    }

    @PostMapping("addGoodsForwardRecord")
    @ApiOperation(value = "添加商品转发记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "客户ID", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "cardId", value = "员工名片ID", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "goodsId", value = "商品ID", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true, company = true,paramClass =GoodsForwardRecordRequest.class)
    public ResultModel addGoodsForwardRecord(@RequestAttribute GoodsForwardRecordRequest request) {
        
        return crmFegin.addGoodsForwardRecord(request);
    }

    @PostMapping("addDynamicForwardRecord")
    @ApiOperation(value = "添加文章转发记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "客户ID", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "cardId", value = "员工名片ID", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "dynamicId", value = "文章/动态ID", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true, company = true,paramClass =DynamicForwardRecordRequest.class)
    public ResultModel addDynamicForwardRecord(@RequestAttribute DynamicForwardRecordRequest request) {
        return crmFegin.addDynamicForwardRecord(request);
    }

}
